package cn.xiu.drugstore.util;

import java.io.InputStream;
import java.util.Properties;

public class ConfigManager {
	// 1:定义了静态的该类私有对象
	private static ConfigManager manager = new ConfigManager();
	private Properties pro = new Properties();

	// 2:只提供私有构造器
	private ConfigManager() {
		try {
			String file = "database.properties";
			InputStream is = ConfigManager.class.getClassLoader()
					.getResourceAsStream(file);
			pro.load(is);// 读取属性列表
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// 3:提供一个静态的公有方法
	public static ConfigManager getInstance() {
		return manager;
	}

	public String getValue(String key) {
		return pro.getProperty(key);
	}
}
